package cn.itcast.user.controller;

import cn.itcast.hmall.pojo.user.Address;
import cn.itcast.user.service.AddressService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("address")
@Slf4j
public class AddressController {

    @Autowired
    private AddressService addressService;

    /**
     * 根据用户id查询地址列表
     */
    @GetMapping("/uid")
    public List<Address> getAddressList(){
        log.info("根据用户id查询地址列表");
        return addressService.getAddressList();
    }


    /**
     * 根据addressId查询地址
     */
    @GetMapping("/{addressId}")
    public Address getAddressID(@PathVariable("addressId") Long addressId){
        log.info("根据addressId:{}查询地址",addressId);
        return addressService.getById(addressId);
    }


}
